<?php
function buildMenu($parentId, $menuData)
{
	if(isset($menuData['parents'][$parentId]))
	{
		$count = count($menuData['parents'][$parentId]);
		$body = ($parentId==0) ? '<ul id="menuMain">' : '<ul>';
		foreach($menuData['parents'][$parentId] as $itemId)
		{
			$body .= "<li>\n";
			$body .= "<a href=\"/{$menuData['items'][$itemId]['Content']['slug']}\">{$menuData['items'][$itemId]['Content']['title']}</a>\n";
			$body .= buildMenu($itemId, $menuData);
			$body .= "</li>\n";
		}
		$body .= '</ul>';
		return $body;
	}
}
//debug($menu_data);
?>
<?php echo buildMenu(0, $menu_data); ?>
